/**
 * 地图导航图例
 * @auther 邓清波
 * @date 2022/11/22
 * */

import mapBusinessApi from './map-business-api'

const iconSize = [30, 35]
const iconAnchor = 'bottom-center'
const zIndex = 111
// 高速图标
const eventIcon = {
  TAB1: 'jtsg', // '交通事故'
  TAB2: 'clgz', // '车辆故障'
  JEB1: 'sgyh', // '施工养护'
  TBB1: 'eltq', // '恶劣天气'
  TDB2: 'zaw', // '障碍物'
  TDB1: 'dll', // '大流量'
  JGB1: 'jtgz'
}

const config = [
  {
    name: '路况',
    model: 'line',
    type: 'lk',
    active: true, // process.env.NODE_ENV !== 'development',
    timer: 60 * 2,
    img: [require('../images/legend/congested-road.png'), require('../images/legend/congested-road-active.png')],
    zIndex: zIndex - 50,
    queryData: mapBusinessApi.getLiveTrafficLine
  },
  {
    name: '摄像机',
    type: 'sxj',
    model: 'label-marker',
    iconSize,
    iconAnchor: 'bottom-center',
    img: [require('../images/legend/camera.png'), require('../images/legend/camera-active.png')],
    iconFilter: ['roadType', ([roadType]) => (roadType == 2 ? 'zhdd-gl-sxj' : 'zhdd-gs-sxj')],
    queryData: mapBusinessApi.getCameraPoint,
    zIndex
  },
  {
    name: '情报板',
    type: 'qbb',
    iconSize,
    model: 'label-marker',
    iconAnchor,
    img: [require('../images/legend/information-board.png'), require('../images/legend/information-board-active.png')],
    className: 'menu-layer-qbb',
    iconFilter: ['roadType', ([roadType]) => (roadType == 2 ? 'zhdd-gl-qbb' : 'zhdd-gs-qbb')],
    queryData: mapBusinessApi.getIntelligenceBoard,
    zIndex
  },
  {
    name: '交调点',
    type: 'jdd',
    model: 'label-marker',
    iconAnchor,
    iconSize,
    img: [require('../images/legend/cross-point.png'), require('../images/legend/cross-point-active.png')],
    className: 'menu-layer-jdd',
    iconFilter: ['type', ([type]) => 'zhdd-gl-jdd'],
    queryData: mapBusinessApi.getHandPoint,
    zIndex
  },
  {
    name: '应急基地',
    type: 'yjjd',
    model: 'label-marker',
    iconAnchor,
    iconSize,
    img: [require('../images/legend/emergency-base.png'), require('../images/legend/emergency-base-active.png')],
    className: 'menu-layer-yjjd',
    iconFilter: ['type', ([type]) => 'zhdd-gl-yjjd'],
    queryData: mapBusinessApi.getEmergencyBase,
    zIndex
  },
  {
    name: '疫情防控',
    type: 'yqfk',
    model: 'label-marker',
    iconAnchor,
    iconSize,
    img: [require('../images/legend/epidemic.png'), require('../images/legend/epidemic-active.png')],
    className: 'menu-layer-yqfk',
    iconFilter: ['type', ([type]) => 'zhdd-gl-yqfk'],
    queryData: mapBusinessApi.getEpidemic,
    zIndex
  },
  {
    name: '高速事件',
    type: 'dlsj',
    model: 'label-marker',
    iconAnchor,
    timer: 60,
    img: [require('../images/legend/road-event.png'), require('../images/legend/road-event-active.png')],
    className: 'menu-layer-dlsj',
    iconSize,
    iconFilter: [
      'eventType',
      ([eventType]) => {
        return 'zhdd-gs-' + eventIcon[eventType]
      }
    ],
    queryData: mapBusinessApi.getHighSpeed,
    zIndex
  },
  {
    name: '摄像机',
    type: 'jjj-sxj',
    model: 'label-marker',
    iconSize,
    iconAnchor: 'bottom-center',
    img: [require('../images/legend/jjj-sxj.png'), require('../images/legend/jjj-sxj-active.png')],
    iconFilter: ['type', ([type]) => 'jjj-gs-sxj'],
    queryData: mapBusinessApi.getConstructionCamera,
    zIndex
  },
  {
    name: '桥梁',
    model: 'label-marker',
    type: 'qmjc',
    img: [require('../images/legend/bridge-monitoring.png'), require('../images/legend/bridge-monitoring-active.png')],
    iconFilter: ['type', ([type]) => 'zhdd-gs-qmjc'],
    zIndex: 101,
    queryData: mapBusinessApi.getBridgePoint
  },
  {
    name: '信号灯',
    model: 'label-marker',
    type: 'hld',
    img: [require('../images/legend/traffic-light.png'), require('../images/legend/traffic-light-active.png')],
    iconFilter: ['type', ([type]) => 'zhdd-gs-hld'],
    zIndex: 101,
    queryData: mapBusinessApi.getTrafficLightPoint
  },
  {
    name: '无人机',
    model: 'label-marker',
    type: 'wrj',
    img: [require('../images/legend/UAV.png'), require('../images/legend/UAV-active.png')],
    iconFilter: ['type', ([type]) => 'zhdd-gs-wrj'],
    zIndex: 101
    // queryData: mapBusinessApi.getTrafficLightPoint
  },
  {
    name: '清障车',
    model: 'label-marker',
    type: 'clgj',
    img: [
      require('../images/legend/vehicle-trajectory.png'),
      require('../images/legend/vehicle-trajectory-active.png')
    ],
    iconFilter: ['type', ([type]) => 'zhdd-gs-clgj'],
    zIndex: 101
    // queryData: mapBusinessApi.getTrafficLightPoint
  }
]

export const getMenuConfig = type => {
  const index = config.findIndex(i => i.type === type)
  return index > -1 ? config[index] : null
}
